package com.promote.algorithm;

/**
 * @ClassName FindMax
 * Description 最大连续1的个数
 * @Author LiZiHao
 * Date 2021/6/29 10:21
 * @Version 1.0
 **/
public class FindMax {

    public static int findMax(int[] nums) {
        int maxCount = 0;
        int count = 0;
        int n = nums.length;
        for (int i = 0; i < n; i++) {
            if (nums[i] == 1) {
                count ++;
            } else {
                maxCount = Math.max(maxCount,count);
                count = 0;
            }
        }
        maxCount = Math.max(maxCount,count);
        return maxCount;
    }

    public static void main(String[] args) {
        int nums[] =new int[]{1,1,0,1,1,1};
        final int max = findMax(nums);
        System.out.println(max);
    }
}
